<?php

namespace My\Model;

use Utuo\UtuoModel;

class ProductModel extends UtuoModel {
	// 楼盘状态
	public $status = array(
			0 => '禁止',
			1 => '正常' 
	);
	
	// 自动验证
	protected $_validate = array(
			array(
				'name',
				'require',
				'商城名称不能为空',
				self::EXISTS_VALIDATE 
			) 
	);
	
	// 自动完成
	protected $_auto = array(
			array('slide_images', 'getSlideConfig', self::MODEL_BOTH, 'callback'),
	);
	
	
	// 轮播图
	public function getSlideConfig() {
		if(!isset($_REQUEST['slide_images'])) return false;
		$slide_images = I("slide_images");
		$result = array();
		foreach ($slide_images as $v) $v['img'] and $result[] = array('img' => $v['img'], 'title' => $v['title'], 'url' =>  $v['url']);
		return serialize($result);
	}
	
}